package com.longcai.service.impl.customer;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.longcai.bean.ApiResult;
import com.longcai.entity.customer.ClyjGift;
import com.longcai.mapper.customer.ClyjGiftMapper;
import com.longcai.service.customer.ClyjGiftService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 礼包表 服务实现类
 * </p>
 *
 * @author M
 * @since 2019-04-18
 */
@Service
public class ClyjGiftServiceImpl extends ServiceImpl<ClyjGiftMapper, ClyjGift> implements ClyjGiftService {
    private Logger logger = LoggerFactory.getLogger(getClass());
    @Autowired
    private ClyjGiftMapper clyjGiftMapper;

    /**
     * 获取所有礼包
     *
     * @return
     */
    @Override
    public ApiResult getGiftList() {
        try {
            QueryWrapper<ClyjGift> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("type", 1);
            List<ClyjGift> clyjGiftList = this.clyjGiftMapper.selectList(queryWrapper);
            logger.debug("查询成功", clyjGiftList);
            return ApiResult.success(clyjGiftList);
        } catch (Exception e) {
            logger.error("查询失败", e);
            e.printStackTrace();
            return ApiResult.fail("修改失败"+e.getMessage());
        }
    }
}
